<template>
	<view class="afterSales-contanier">
		<view class="module goods-list-content">
			<view class="title">退货商品<text class="desc">(请选择下方商品)</text></view>
			<view class="goods-list" v-for="(v,i) in order.orderGoodsList" :key="i">
				<view class="item" :class="{active:goodsCheckedIds==v.orderGoodsId}" @click="goodsChange(v.orderGoodsId)">
					<u--image :src="v.image.url" radius="5" width="80px" height="80px" mode="scaleToFill"></u--image>
				</view>
			</view>
		</view>
		<view class="module service-type" v-if="step">
			<view class="title">选择服务商品</view>
			<view class="type-content">
				<view class="item" v-for="(v,i) in refundType.data" :key="i"  @click="typeChange(v.value)">
					<unt-icon :name="v.icon" size="19" color="#E96133"></unt-icon>
					<view class="text">{{v.name}}</view>
					<unt-icon name="icon-arrow" size="12" color="#999999" style="margin-left: auto;"></unt-icon>
				</view>
			</view>
		</view>
		<refund-sales :order="order" :goodsId="goodsCheckedIds" :type="type" style="width: 100%;" v-else ></refund-sales>
	</view>
</template>

<script>
	import { refundType } from '@/common/enum/refund'
	import refundSales from '../components/refundSales'
	import * as Order from '@/api/order/index.js'
	export default {
		components:{
			refundSales
		},
		data() {
			return {
				type:10,
				refundType,
				step:true,
				goodsCheckedIds:'',
				isLoading: false,
				options: {},
				order: {}
			}
		},
		onLoad(options) {
			this.options = options;
			this.getOrderDetail();
		},
		methods: {
			typeChange(val){
				this.type=val;
				this.step=false;
			},
			goodsChange(id){
				this.goodsCheckedIds=id;
				// const index = this.goodsCheckedIds.indexOf(id);
				// index < 0 ? this.goodsCheckedIds.push(id) : this.goodsCheckedIds.splice(index, 1);
			},
			getOrderDetail() {
				const id = this.options.orderId;
				Order.detail({
					orderId: id
				}).then(res => {
					this.order = res.data;
					this.isLoading = true;
				}).catch(err => err)
			},
		}
	}
</script>
<style>
	page {
		background: #F0F0F0;
	}
</style>
<style lang="scss" scoped>
	.afterSales-contanier {
		position: relative;
		width: 100%;
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;
		padding: 0px 20rpx;
		.module {
			width: 100%;
			background: #fff;
			padding: 20rpx;
			border-radius: 25rpx;
			margin-top: 30rpx;

			.title {
				margin-bottom: 20rpx;
				font-weight: 600;
				font-size: 30rpx;
				display: flex;
				    justify-content: space-between;
				.desc{
					margin-left: 10rpx;
					    font-size: 28rpx;
					    font-weight: 500;
				}
			}

			.type-content {
				margin-top: 50rpx;

				.item {
					display: flex;
					justify-content: flex-start;
					margin-bottom: 50rpx;

					.text {
						margin-left: 15rpx;
					}
				}
			}
		}

		.goods-list {
			display: flex;
			justify-content: flex-start;
			flex-wrap: wrap;

			.item {
				position: relative;
				border: 1px dashed #01ab63;
				padding: 5rpx;
				border-radius: 10rpx;
			}

			.item.active::before {
				content: '✓';
				position: absolute;
				left: 0px;
				top: 0px;
				width: 100%;
				height: 100%;
				background-color: rgba(0, 0, 0, .41);
				z-index: 99;
				border-radius: 10rpx;
				color: #fff;
				font-size: 50rpx;
				text-align: center;
				line-height: 160rpx;
			}
		}

	}
</style>